package com.cntv.viewbindingdemo

import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import com.cntv.viewbindingdemo.databinding.FragmentVBBinding

class VBFragment : Fragment() {
    private lateinit var viewBinding: FragmentVBBinding//和本类名对应

    override fun onCreateView(
        inflater: LayoutInflater,
        container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        viewBinding = FragmentVBBinding.inflate(getLayoutInflater())
        return viewBinding.root
    }

    var size: Float = 16f
    override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
        viewBinding.fragment.text = "hello,我是fragment"
        viewBinding.button.setOnClickListener {
            if (size < 40) {
                size += 2
            } else {
                size = 16f
            }
            viewBinding.fragment.textSize= size
        }
    }
}